//
//  MXSStateTableVC.swift
//  weibo
//
//  Created by 孙飞 on 15/12/7.
//  Copyright © 2015年 Sunfei. All rights reserved.
//

import UIKit

class MXSStateTableVC: UITableViewController {

//    var isUserLogin = true
    var isUserLogin = MXSUserAccountVM.sharedAccount.accessToken != nil
    
    var visitorer: MXSVisitorView?
    
    override func loadView() {
        isUserLogin ? super.loadView() : setupVisitorView()
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    private func setupVisitorView(){
    
        visitorer = MXSVisitorView()
        
        visitorer?.registerBtn.addTarget(self, action: "login", forControlEvents: UIControlEvents.TouchUpInside)
        visitorer?.loginBtn.addTarget(self, action: "login", forControlEvents: UIControlEvents.TouchUpInside)
        view = visitorer
        
        navigationItem.leftBarButtonItem = UIBarButtonItem.init( title: "注册", target: self, action: "login")
        navigationItem.rightBarButtonItem = UIBarButtonItem.init( title: "登陆", target: self, action: "login")
        
    }
    
    @objc private func login(){
        
        print("login")
        let loginVC = MXSOAuthVC()
//        navigationController?.pushViewController(loginVC, animated: true)
        presentViewController(MXSNavController(rootViewController: loginVC), animated: true, completion: nil)
    }
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    
}
